package com.gd.iot.energy.controller.dailymanage;

import com.gd.iot.energy.annotation.SystemLogRecordMonitor;
import com.gd.iot.energy.entity.ResponseEntity;
import com.gd.iot.energy.pojo.common.vo.PageVO;
import com.gd.iot.energy.pojo.dailymanage.vo.ChargeBookPageVO;
import com.gd.iot.energy.pojo.dailymanage.vo.ChargeQueryPageVO;
import com.gd.iot.energy.pojo.dailymanage.vo.ChargeStatisticsPageVO;
import com.gd.iot.energy.pojo.dailymanage.vo.InvoicePageVO;
import com.gd.iot.energy.service.dailymanage.OperationfeeChargeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 日常管理-财务管理-发票管理
 *
 * @author kris
 * @date Created at 2020/8/7 10:50
 */
@Api(value = "日常管理-财务管理-发票管理",tags = "日常管理-财务管理-发票管理")
@RestController
@RequestMapping("/admin/finance")
public class InvoiceController {

    @Autowired
    private OperationfeeChargeService operationfeeChargeService;

    @ApiOperation("发票管理分页列表")
    @SystemLogRecordMonitor("发票管理分页列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "customerSerialnumber", value = "客户编号", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "hasInvoice", value = "是否开发票，0未开，1已开", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "beginDate", value = "开始日期", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "endDate", value = "结束日期", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderColumn", value = "排序字段", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderType", value = "排序类型(asc,desc)", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/getInvoicePageVO")
    public ResponseEntity<PageVO<InvoicePageVO>> getInvoicePageVO(
            @RequestParam(value = "customerSerialnumber",required = false)String customerSerialnumber,
            @RequestParam(value = "customerName",required = false)String customerName,
            @RequestParam(value = "hasInvoice",required = false)Integer hasInvoice,
            @RequestParam(value = "beginDate",required = false)String beginDate,
            @RequestParam(value = "endDate",required = false)String endDate,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize,
            @RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum,
            @RequestParam(value = "orderColumn",required = false,defaultValue = "a.pay_time") String orderColumn,
            @RequestParam(value = "orderType",required = false,defaultValue = "desc") String orderType
    ) {

        PageVO<InvoicePageVO> pageVO = operationfeeChargeService.getInvoicePageVO(customerSerialnumber,customerName,hasInvoice,
                beginDate,endDate,pageSize,pageNum,orderColumn,orderType);
        return new ResponseEntity<>(pageVO);
    }

    @ApiOperation("开票")
    @SystemLogRecordMonitor("开票")
    @PostMapping("/invoice")
    public ResponseEntity invoice(@RequestBody List<Integer> ids) {

        operationfeeChargeService.invoice(ids);
        return new ResponseEntity<>();
    }

    @ApiOperation("开票记录分页列表")
    @SystemLogRecordMonitor("开票记录分页列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "customerSerialnumber", value = "客户编号", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "beginDate", value = "开始日期", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "endDate", value = "结束日期", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/getInvoiceRecordPageVO")
    public ResponseEntity<PageVO<InvoicePageVO>> getInvoiceRecordPageVO(
            @RequestParam(value = "customerSerialnumber",required = false)String customerSerialnumber,
            @RequestParam(value = "customerName",required = false)String customerName,
            @RequestParam(value = "beginDate",required = false)String beginDate,
            @RequestParam(value = "endDate",required = false)String endDate,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize,
            @RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum
    ) {

        PageVO<InvoicePageVO> pageVO = operationfeeChargeService.getInvoiceRecordPageVO(customerSerialnumber,customerName,
                beginDate,endDate,pageSize,pageNum);
        return new ResponseEntity<>(pageVO);
    }
}
